﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows;

namespace Drawing
{
    public class CLine : Shapes
    {


        public CLine(Point _StartupPosition, Point _LastPosition)
            : base(_StartupPosition, _LastPosition)
        {
            m_TypeColor = TypeColor.BORDER;
            m_Type = TypeShape.LINE;
            m_DeltaX = _LastPosition.X - _StartupPosition.X;
            m_DeltaY = _LastPosition.Y - _StartupPosition.Y;
        }

        public CLine(Point _StartupPosition, int _DeltaX, int _DeltaY)
            : base(_StartupPosition)
        {
            m_TypeColor = TypeColor.BORDER;
            m_Type = TypeShape.LINE;

            m_DeltaX = _DeltaX;
            m_DeltaY = _DeltaY;

            m_LastPosition.X = _StartupPosition.X + _DeltaX;
            m_LastPosition.Y = _StartupPosition.Y + _DeltaY;
        }

        public override bool IsContain(Point _PointOfPointer)
        {
            Point _vector1 = new Point(m_LastPosition.X - m_StartupPosition.X, m_LastPosition.Y - m_StartupPosition.Y);
            Point _vector2 = new Point(_PointOfPointer.X - m_StartupPosition.X, _PointOfPointer.Y - m_StartupPosition.Y);

            if ((int)(_vector1.X / _vector2.X) == (int)(_vector1.Y / _vector2.Y) && (_vector2.X != 0 && _vector2.Y != 0))
            {
                m_IsSelected = true;
            }
            else
            {
                m_IsSelected = false;
            }
            return m_IsSelected;
        }

    }
}
